ans = []
num = 0
for i in range(int(input())):
ar = input().split()
first_to_int = int(ar[0])
second_to_int = int(ar[1])
if i == 0:
if first_to_int>= second_to_int:
num -= second_to_int
ans.append("G")
continue
else:
num += first_to_int
ans.append("A")
continue
if abs(num + first_to_int) < abs(num - second_to_int):
num += first_to_int
ans.append("A")
elif abs(num+first_to_int) >= abs(num-second_to_int):
num -= second_to_int
ans.append("G")
if num <= 500:
print("".join(ans))
else:
print("-1")
#include <bits/stdc++.h>
using namespace std;
#define faster ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl cout << "\n"
#define ll long long
#define lli long long int
#define lp(i, a, n) for (ll i =a; i < n; i++)
#define rlp(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define sortAll(x) sort(x.begin(), x.end())
#define sortRall(x) sort(x.rbegin(), x.rend())
#define out(x) cout << x << '\n'
#define pb(x) push_back(x)
#define coutarr(x, n) for (int i = 0; i < (int)n; i++) cout << x[i] << " ";cout << "\n";
#define coutvec(vec) for (ll i = 0; i < vec.size(); i++) cout << vec[i] << " ";cout << "\n";
#define cinarr(x, n) for (int i = 0; i < (int)n; i++) cin >> x[i];
#define cinAndPush(arr, n, vec) for (ll i = 0; i < n; i++) cin >> arr[i], vec.push_back(arr[i]);
#define cinArrSum(arr,n,sum) for(ll i=0; i<n; i++) cin>>arr[i],sum+=arr[i];
ll gcd(ll x, ll y)
{
if (y == 0)
return x;
return gcd(y, x % y);
}
bool check(ll arr[], ll n)
{
}
ll factorial(ll n)
{
return (n==1 || n==0) ? 1: n * factorial(n - 1);
}
ll ans=0;
void solve(string s)
{
if(s[1]=='+'){
ans++;
}
else
{
ans--;
}
}
int main()
{
faster;
ll n; cin>>n;
ll tol=0;
string keep;
while (n--)
{
ll sa,sg;
cin>>sa>>sg;
if(sa+tol <=500)
{
tol+=sa;
keep+='A';
}
else
{
tol-=sg;
keep+='G';
}
}
out(keep);
}
733. Flood Fill | 206. Reverse Linked List |
83. Remove Duplicates from Sorted List | 116. Populating Next Right Pointers in Each Node |
145. Binary Tree Postorder Traversal | 94. Binary Tree Inorder Traversal |
101. Symmetric Tree | 77. Combinations |
46. Permutations | 226. Invert Binary Tree |
112. Path Sum | 1556A - A Variety of Operations |
136. Single Number | 169. Majority Element |
119. Pascal's Triangle II | 409. Longest Palindrome |
1574A - Regular Bracket Sequences | 1574B - Combinatorics Homework |
1567A - Domino Disaster | 1593A - Elections |
1607A - Linear Keyboard | EQUALCOIN Equal Coins |
XOREQN Xor Equation | MAKEPAL Weird Palindrome Making |
HILLSEQ Hill Sequence | MAXBRIDGE Maximise the bridges |
WLDRPL Wildcard Replacement | 1221. Split a String in Balanced Strings |
1002. Find Common Characters | 1602A - Two Subsequences |